#include "StdAfx.h"
#include "MaterialManager.h"

VAMPIRE_NAMESPACE_BEGIN

Material* MaterialManager::createMaterial( const TString& name, RenderPriorityGroup priority )
{
	if (mMaterialMap[name])
	{
		return mMaterialMap[name];
	}


	Material*  material = new Material(name);

	material->mRPG = priority;
	material->mpTexturePtr = 
		TextureFactory::getSingletonPtr()->createTextureFromFile(material->getRPG().mTextureName);
	material->initEffect();

	Root::getSingletonPtr()->getRenderManager()->addMaterial(material);
	
	mMaterialMap[name] = material;

	return material;

}

REGISTER_HELPER_IMPLEMENT(MaterialManager);

VAMPIRE_NAMESPACE_END
